﻿$(document).ready(function () {
    $("#btt-compare").click(function () {
        var id = $("#ListPhone").val();
        $.getJSON("/Ajax/GetPhoneByID", { ID_SP: id }, function (data) {
            $("#TenSanPham").text(data.TenSanPham);
            $("#AnhDaiDien").html("<img src=\"" + data.AnhDaiDien + "\" />");
            $("#DonGia").text(data.DonGia);
            $("#TinhNangNoiBat").text(data.TinhNangNoiBat);
            $("#TrangThaiPhatHanh").text(data.TrangThaiPhatHanh);
            $("#NgayPhatHanh").text(data.NgayPhatHanh);
            $("#BangTan").text(data.BangTan);
            $("#ChieuDai").text(data.ChieuDai);
            $("#ChieuRong").text(data.ChieuRong);
            $("#ChieuCao").text(data.ChieuCao);
            $("#TrongLuong").text(data.TrongLuong);
            $("#KieuManHinh").text(data.KieuManHinh);
            $("#KichThuocManHinh").text(data.KichThuocManHinh);
            $("#DoPhanGiai").text(data.DoPhanGiai);
            $("#CamUng").text(data.CamUng);
            $("#TinhNangKhac").text(data.TinhNangKhac);
            $("#AmBao").text(data.AmBao);
            $("#JackAudio").text(data.JackAudio);
            $("#LoaNgoai").text(data.LoaNgoai);
            $("#DanhBaLuuTru").text(data.DanhBaLuuTru);
            $("#BoNhoTrong").text(data.BoNhoTrong);
            $("#HoTroTheNho").text(data.HoTroTheNho);
            $("#GPRS").text(data.GPRS);
            $("#EDGE").text(data.EDGE);
            $("#C3G").text(data.C3G);
            $("#TrinhDuyetWeb").text(data.TrinhDuyetWeb);
            $("#GPS").text(data.GPS);
            $("#Bluetooth").text(data.Bluetooth);
            $("#Wifi").text(data.Wifi);
            $("#HongNgoai").text(data.HongNgoai);
            $("#USB").text(data.USB);
            $("#MayAnhChinh").text(data.MayAnhChinh);
            $("#MayAnhPhu").text(data.MayAnhPhu);
            $("#DinhDangNhac").text(data.DinhDangNhac);
            $("#DinhDangPhim").text(data.DinhDangPhim);
            $("#Radio").text(data.Radio);
            $("#UngDung").text(data.UngDung);
            $("#HoTroJava").text(data.HoTroJava);
            $("#HoTroNhieuSim").text(data.HoTroNhieuSim);
            $("#KieuDang").text(data.KieuDang);
            $("#HeDieuHanh").text(data.HeDieuHanh);
            $("#Chip").text(data.Chip);
            $("#RAM").text(data.RAM);
            $("#NgonNgu").text(data.NgonNgu);
            $("#LoaiBanPhim").text(data.LoaiBanPhim);
            $("#Pin").text(data.Pin);
        });
    });

    /*-----------------------------------------------------------------------------------*/

    $('#Search-Input-In-Layout').keyup(function () {
        var keyword = $(this).val();
        if (keyword != '') {
            $.get('/Ajax/GetQuickResult', { Name: keyword }, function (html) {
                $('#quick-result-display-layout').html(html);
            });
        } else {
            $('#quick-result-display-layout').empty();
        }
    });

    $('#Search-Input-In-Layout').focus(function () {
        var keyword = $(this).val();
        if (keyword != '') {
            $.get('/Ajax/GetQuickResult', { Name: keyword }, function (html) {
                $('#quick-result-display-layout').html(html);
            });
        } else {
            $('#quick-result-display-layout').empty();
        }
    });

    $('#Search-Input-In-Layout').blur(function () {
        setTimeout(function () {
            $('#quick-result-display-layout').empty();
        }, 100)

    });

    /*-----------------------------------------------------------------------------------*/

    $('#Search-Input-In-Page').keyup(function () {
        var keyword = $(this).val();
        if (keyword != '') {
            $.get('/Ajax/GetQuickResult', { Name: keyword }, function (html) {
                $('#quick-result-display').html(html);
            });
        } else {
            $('#quick-result-display').empty();
        }
    });

    $('#Search-Input-In-Page').focus(function () {
        var keyword = $(this).val();
        if (keyword != '') {
            $.get('/Ajax/GetQuickResult', { Name: keyword }, function (html) {
                $('#quick-result-display').html(html);
            });
        } else {
            $('#quick-result-display').empty();
        }
    });

    $('#Search-Input-In-Page').blur(function () {
        setTimeout(function () {
            $('#quick-result-display').empty();
        }, 100)
    });

    $('#CatalogType').change(function () {
        var html = '<option value="">Tất cả</option>';
        $.getJSON('/Ajax/GetListCatalogByTypeID', { id: $(this).val() }, function (data) {
            $.each(data, function (i, item) {
                html += '<option value="' + item.MaDanhMuc + '">' + item.TenDanhMuc + '</option>';
            });
            $('#CatalogList').html(html);
        });
    });
});